package com.weiqiao.api.rest;

import com.weiqiao.aop.log.Log;
import com.weiqiao.api.domain.ApiResponseEntity;
import com.weiqiao.api.domain.BankApiEntity;
import com.weiqiao.api.domain.CardCommodityApiEntity;
import com.weiqiao.api.domain.vo.BankApiVO;
import com.weiqiao.api.domain.vo.CardCommodityApiVO;
import com.weiqiao.api.service.IBankApiService;
import com.weiqiao.api.service.ICardCommodityApiService;
import com.weiqiao.api.until.ApiResUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("mallApi/core/api/")
public class BankApiController {

    /**
     * 银行列表
     */
    @Autowired
    private IBankApiService bank;

    /**
     * 信用卡产品表
     */
    @Autowired
    private ICardCommodityApiService cardCommodityApiService;

    @Log("根据条件获得热门银行列表")
    @GetMapping("bank-list")
    public ApiResponseEntity bankList(@Validated BankApiVO vo) {
        List<BankApiEntity> list = bank.hotBankList(vo);
        return ApiResUtil.buildRes(true, "热门银行列表", list);
    }

    @Log("根据条件获得热门银行详情")
    @GetMapping("bank-detail")
    public ApiResponseEntity bankDeatil(@Validated BankApiVO vo) {
        List<BankApiEntity> list = bank.hotBankDetail(vo);
        return ApiResUtil.buildRes(true, "热门银行详情", list);
    }

    @Log("根据条件银行卡列表")
    @GetMapping("bank-card-list")
    public ApiResponseEntity bankCardList(@Validated CardCommodityApiVO vo) {
        List<CardCommodityApiEntity> list = cardCommodityApiService.findCommoditys(vo);
        return ApiResUtil.buildRes(true, "银行卡列表", list);
    }

}
